package com.xbs.utils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 角色名称更改
 */
import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.RoleEntity;
import com.xbs.service.content.RoleAdminService;
@WebServlet("/ajaxup")
public class AjaxRoleUpServlet extends BaseServlet {
	private RoleAdminService rs;
	private List<RoleEntity> relst;
	public AjaxRoleUpServlet() {
		rs = new RoleAdminService();
		relst = new ArrayList<RoleEntity>();
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//要修改的角色名称
		String yname = req.getParameter("yname");
		//要修改成的角色名称
		String uname = req.getParameter("uname");
		rs.up(yname, uname);
		
		
		relst = rs.selRole();
		String str="<tr>"
				+ "<th>全选<input type='checkbox' class='choice' id='box' onclick='getCheck(id)'/></th>"
				+ "<th>角色名称</th>"
				+ "<th>操作</th>"
				+ "</tr>";
		for(RoleEntity re:relst){
			str+="<tr>"
				+ "<td><input type='checkbox' class='checked' name='ck' onclick='getChild()' value=\""+re.getRoleid()+"\"/></td>"
				+ "<td>"+re.getRolename()+"</td>"
				+ "<td>"
				+ "<input class='update' type='button' value='修 改'  class='pointer' onclick='getName(\""+re.getRolename()+"\")'/>"
				+ "</td>"
				+ "</tr>";
		}
		resp.getWriter().print(str);
	}
}
